home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / DOSSUB2.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  4KB  |  162 lines

  1. ; DOSSUB2 - general dos subroutine interface for compiled BASIC
  2. ; Copyright 1983 Data Base Decisions
  3. ; CALL DOSSUB2(RETCD%,INTNO%,ES%,SI%,DI%,AH%,AL%,BH%,BL%,CH%,CL%,DH%,DL%)
  4. ; RETCD% is the error return code (0 if no error)
  5. ; INTNO% is the interrupt number (0 to 255)
  6. ; ES% is the argument corresponding to register ES
  7. ; SI% is the argument corresponding to register SI
  8. ; DI% is the argument corresponding to register DI
  9. ; AH% is the argument corresponding to register AH
  10. ; AL% is the argument corresponding to register AL
  11. ; BH% is the argument corresponding to register BH
  12. ; BL% is the argument corresponding to register BL
  13. ; CH% is the argument corresponding to register CH
  14. ; CL% is the argument corresponding to register CL
  15. ; DH% is the argument corresponding to register DH
  16. ; DL% is the argument corresponding to register DL
  17.  
  18. cseg    segment para public 'code'
  19. public    dossub2
  20. dossub2 proc far
  21.     assume cs:cseg,ds:nothing,ss:nothing,es:nothing
  22.     push bp
  23.     mov bp,sp
  24.  
  25. p20:                ; temporarily change fatal error vector
  26.     push ds         ; push 1
  27.     push es         ; push 2
  28.     xor ax,ax
  29.     mov ds,ax
  30.     mov ax,[ds:90h]     ; get fatal error ip
  31.     push ax         ; save ip - push 3
  32.     mov ax,[ds:92h]     ; get fatal error cs
  33.     push ax         ; save cs - push 4
  34.     call p25        ; get ip - push 5a
  35.  
  36. p25:
  37. a25    equ this byte
  38.     pop bx            ; ip in bx - pop 5a
  39.     add bx,a50-a25
  40.     mov ds:90h,bx        ; ip of vector
  41.     push cs         ; set fatal error cs - push 5b
  42.     pop ax            ; set ds to cs - pop 5b
  43.     mov ds:92h,ax        ; cs of vector
  44.     push es         ; push 5c
  45.     pop ds            ; restore ds - pop 5c
  46.  
  47. p30:                ; set registers for call
  48.     mov si,[bp+20]        ; point to ah argument
  49.     mov ah,[si]
  50.     mov si,[bp+18]        ; point to al argument
  51.     mov al,[si]
  52.     mov si,[bp+16]        ; point to bh argument
  53.     mov bh,[si]
  54.     mov si,[bp+14]        ; point to bl argument
  55.     mov bl,[si]
  56.     mov si,[bp+12]        ; point to ch argument
  57.     mov ch,[si]
  58.     mov si,[bp+10]        ; point to cl argument
  59.     mov cl,[si]
  60.     mov si,[bp+8]        ; point to dh argument
  61.     mov dh,[si]
  62.     mov si,[bp+6]        ; point to dl argument
  63.     mov dl,[si]
  64.     mov si,[bp+22]        ; point to di argument
  65.     mov di,[si]
  66.     mov si,[bp+26]        ; point to es argument
  67.     push ax         ; push 5d
  68.     mov ax,[si]        ; es arg in ax
  69.     mov es,ax
  70.     pop ax            ; pop 5d
  71.     mov si,[bp+24]        ; point to si argument
  72.     mov si,[si]
  73.  
  74. p40:                ; set up for call
  75.     push ax         ; push 5e
  76.     push bx         ; push 6
  77.     mov bx,[bp+28]        ; point to interrupt no
  78.     mov al,[bx]        ; interrupt in al
  79.     call p45        ; push 7
  80.  
  81. p45:
  82. a45    equ this byte
  83.     pop bx            ; ip in bx - pop 7
  84.     add bx,a46-a45+1
  85.     mov cs:[bx],al        ; set interrupt
  86.     pop bx            ; pop 6
  87.     pop ax            ; pop 5e
  88.     push bp         ; save bp - bios bug - push 5f
  89.     clc            ; clear carry
  90.  
  91. a46    equ this byte
  92.     int 00h         ; overlaid by intno%
  93.     jc p48            ; dos 2.0 error
  94.     jmp short p60        ; skip err control
  95.  
  96. p48:                ; dos 2.00 error
  97.     pop bp            ; pop 5f
  98.     mov ah,1        ; indicate dos 2.0 error
  99.     mov si,[bp+30]        ; point to RETCD%
  100.     mov [si],ax        ; save error
  101.     jmp short p70        ; bail out
  102.  
  103. p50:                ; handle fatal error
  104. a50    equ this byte
  105.     sti            ; interrupts back on
  106.     mov ax,di        ; get error code
  107.     mov ah,0        ; error in al
  108.     add sp,20        ; skip unneeded stack
  109.     pop ds
  110.     pop es
  111.     add sp,6        ; skip rest of stack
  112.     pop bp            ; restore bp - bios bug - pop 5f
  113.     mov si,[bp+30]
  114.     mov [si],ax        ; return error
  115.     jmp short p70        ; restore orig vector
  116.  
  117. p60:                ; return register values
  118.     pop bp            ; restore bp - bios bug - pop 5f
  119.     push si         ; save for later - push 5g
  120.     mov si,[bp+20]        ; point to ah argument
  121.     mov [si],ah
  122.     mov si,[bp+18]        ; point to al argument
  123.     mov [si],al
  124.     mov si,[bp+16]        ; point to bh argument
  125.     mov [si],bh
  126.     mov si,[bp+14]        ; point to bl argument
  127.     mov [si],bl
  128.     mov si,[bp+12]        ; point to ch argument
  129.     mov [si],ch
  130.     mov si,[bp+10]        ; point to cl argument
  131.     mov [si],cl
  132.     mov si,[bp+8]        ; point to dh argument
  133.     mov [si],dh
  134.     mov si,[bp+6]        ; point to dl argument
  135.     mov [si],dl
  136.     pop ax            ; get returned si in ax - pop 5g
  137.     mov si,[bp+24]        ; point to si argument
  138.     mov [si],ax
  139.     mov ax,es        ; get returned es in ax
  140.     mov si,[bp+26]        ; point to es argument
  141.     mov [si],ax
  142.     mov si,[bp+22]        ; point to di argument
  143.     mov [si],di
  144.  
  145. p70:                ; reset fatal error vector
  146.     xor ax,ax
  147.     mov ds,ax
  148.     pop ax            ; re-set fatal error vector - pop 4
  149.     mov ds:92h,ax        ; restore original cs
  150.     pop ax            ; pop 3
  151.     mov ds:90h,ax        ; restore original ip
  152.     pop es            ; pop 2
  153.     pop ds            ; pop 1
  154.  
  155. p80:                ; return to caller
  156.     pop bp            ; return to caller
  157.     ret 26
  158.  
  159. dossub2 endp
  160. cseg    ends
  161.     end
  162.